<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算属性基本使用</title>
    <style>
        [v-cloak] {
            display: none;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
    </style>
</head>

<body>
    <div v-cloak>
        <span>单价：</span><input type="text" name="price" v-model.number="price">
        <span>数量：</span><input type="text" name="num" v-model.number="num">
        <span>总价：</span><span>{{sum2}}</span>

        <span>姓：</span><input type="text" name="firstname" v-model.number="firstname">
        <span>名：</span><input type="text" name="lastname" v-model.number="lastname">
        <span>姓名：</span><input name="calcName" v-model="calc">


    </div>

    </div>
    <script src="./js/dev/vue.js"></script>
    <script>
        const app = new Vue({
            el: 'div',
            data: {
                price: 0,
                num: 0,
                firstname: '',
                lastname: '',
                fullname: '',
            },
            computed: {
                sum: function () {
                    return this.price * this.num
                },
                sum2() {
                    return this.price * this.num
                },
                calc: {
                    get() {
                        return this.price * this.num
                    },
                    set(v) {
                        console.log(`v = ${v}`);

                    }
                }
            }
        })
    </script>
</body>

</html>